import notification from "ant-design-vue/es/notification";

export const ACCESS_TOKEN = 'hash_pay_access_token';
export const ACCESS_USER_INFO = 'hash_pay_access_user_info';

export const ACCESS_REMEMBER = "hash_pay_access_remember"

export const UPLOAD_URL = "/file/upload"
import i18n from "@/locale"

export const checkMoney = (rule, value, callback) => {
  if (
    !/(?:^[1-9]([0-9]+)?(?:\.[0-9]{1,2})?$)|(?:^(?:0){1}$)|(?:^[0-9]\.[0-9](?:[0-9])?$)/.test(value)
  ) {
    callback(new Error('请输入正确的金额'))
  } else {
    callback()
  }
}
export const checkZsNum = (rule, value, callback) => {
  if (!/^[1-9]\d*$/.test(value)) {
    callback(new Error('请输入正整数'))
  } else {
    callback()
  }
}

export const checkNum = (rule, value, callback) => {
  if (!/^[0-9]\d*$/.test(value)) {
    callback(new Error('请输入数字'))
  } else {
    callback()
  }
}


export const ErrorMsg = (description,msg = 'Error') => {
  notification.error({
    message: msg,
    description
  })
}
export const SuccessMsg = (description=i18n.t('Operation successful'),msg = i18n.t('Success')) => {
  notification.success({
    message: msg,
    description
  })
}
